package net.csdn.business.common.feign.mirror;

import net.csdn.business.common.constant.ServiceNameConstants;
import net.csdn.business.common.domain.mirror.pop.*;
import net.csdn.business.common.feign.mirror.config.MirrorFeignConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @author likun
 * @date 2023/2/3 10:53
 */
@FeignClient(value = ServiceNameConstants.ATOMGIT_MIRROR_SERVICE, contextId = ServiceNameConstants.ATOMGIT_MIRROR_THIRD_CONTEXT_ID, configuration = MirrorFeignConfiguration.class)
public interface ThirdGitApiFeignClient {
    /**
     * 分页获取用户授权的组织信息
     */
    @PostMapping("/api/v1/mirror/thirdApi/getOrgs")
    MyGithubDto getOrgs(@RequestBody GitOrgDto gitOrgDto);

    /**
     * 分页获取用户授权的仓库信息
     */
    @PostMapping("/api/v1/mirror/thirdApi/getRepos")
    MyGithubDto getRepos(@RequestBody GitRepoDto gitRepoDto);


    /**
     * 根据token获取用户信息
     */
    @PostMapping("/api/v1/mirror/thirdApi/getUserByToken")
    UserBO getUserByToken(@RequestBody GitAuthorizeDto authorizeDto);


    /**
     * 获取授权信息code并重定向
     */
    @GetMapping("/api/v1/mirror/thirdApi/authorize/{platform}")
    String authorize(@PathVariable("platform") String platform);


    /**
     * 根据code和具体哪个平台获取token信息
     */
    @PostMapping("/api/v1/mirror/thirdApi/token")
    UserTokenVo getToken(@Validated @RequestBody GitAuthorizeDto authorizeDto);
}